﻿using System;
using System.Collections.Generic;
using System.Text;
using Includes;

namespace Arztmodul
{
    /// <summary>
    /// Version: 1.2
    ///  Author: Jan Baltzer
    ///    Date: 2012-05-29
    /// includes all properties of /HCSA1010/ and some for BackEnd
    /// </summary>
    public class Patient
    {
        //properties of /HCSA1010/

        /// <summary> Patients last name </summary>
        public string name { set; get; }
        /// <summary> Patients first name </summary>
        public string firstName { set; get; }
        /// <summary> Patients date of birth </summary>
        public DateTime dateOfBirth { set; get; }
        /// <summary> Patients gender </summary>
        public Gender gender { set; get; }
        /// <summary> Patients diagnosis </summary>
        public string diagnosis { set; get; }
        /// <summary> Patients telephone number </summary>
        public string telephoneNumber { set; get; }
        /// <summary> NOKs telephone number </summary>
        public string secondTelephoneNumber { set; get; }
        /// <summary> Patients ideal blood pressure </summary>
        public int normalBloodPressure { set; get; }
        /// <summary> Patients acceptable deviation for blood pressure in % </summary>
        public int acceptableBloodPressure { set; get; }
        /// <summary> Patients critical deviation for blood pressure in % </summary>
        public int criticalBloodPressure { set; get; }
        /// <summary> Patients ideal pulse </summary>
        public int normalPulse { set; get; }
        /// <summary> Patients acceptable deviation for pulse in % </summary>
        public int acceptablePulse { set; get; }
        /// <summary> Patients critical deviation for pulse in % </summary>
        public int criticalPulse { set; get; }
        /// <summary> Patients ideal weight </summary>
        public int normalWeight { set; get; }
        /// <summary> Patients acceptable deviation for weight in % </summary>
        public int acceptableWeight { set; get; }
        /// <summary> Patients critical deviation for weight in % </summary>
        public int criticalWeight { set; get; }
        /// <summary> Patients status </summary>
        public Status status { set; get; }
        /// <summary> First time to expect vitaldata transmissions for the patient </summary>
        public DateTime checkTime1 { set; get; }
        /// <summary> Second time to expect vitaldata transmissions for the patient </summary>
        public DateTime checkTime2 { set; get; }

        //properties for logic (BackEnd)
        /// <summary> Whether the patient is expected in the Hospital </summary>
        public bool kr { set; get; }
        /// <summary> Patient ID </summary>
        public int id { set; get; }

        private Patient()
        {
            this.acceptableBloodPressure = 20;
            this.criticalBloodPressure = 30;

            this.acceptablePulse = 20;
            this.criticalPulse = 30;
            
            this.acceptableWeight = 20;
            this.criticalWeight = 30;
            
            this.checkTime1 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 9, 0, 0);
            this.checkTime2 = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 21, 0, 0);    
            
            this.status     = Status.Keiner;

            //properties for logic (BackEnd)
            this.kr = false;
            this.id = 0;
        }

        /// <summary>
        /// tiny constructor to create new Patient
        /// </summary>
        /// <param name="name">name of Patient</param>
        /// <param name="firstName">first name of Patient</param>
        public Patient(string name, string firstName) : this()
        {
            this.name = name;
            this.firstName = firstName;
        }

        /// <summary>
        /// full constructor to create an initialized Patient
        /// </summary>
        /// <param name="name">name of Patient</param>
        /// <param name="firstName">first name of Patient</param>
        /// <param name="dayOfBirth">day of birth of Patient</param>
        /// <param name="gender">gender of Patient</param>
        /// <param name="diagnosis">diagnosis of Patient</param>
        /// <param name="telephoneNumber">telephone number of Patient</param>
        /// <param name="secondTelephoneNumber">telephone number of second contact of Patient</param>
        /// <param name="normalBloodPressure">normal blood pressure of Patient</param>
        /// <param name="acceptableBloodPressure">acceptable blood pressure anomaly of Patient</param>
        /// <param name="criticalBloodPressure">critical blood pressure anomaly of Patient</param>
        /// <param name="normalPulse">normal pulse of Patient</param>
        /// <param name="acceptablePulse">acceptable pulse anomaly of Patient</param>
        /// <param name="criticalPulse">critical pulse anomaly of Patient</param>
        /// <param name="normalWeight">normal weight of Patient</param>
        /// <param name="acceptableWeight">acceptable weight anomaly of Patient</param>
        /// <param name="criticalWeight">critical weight anomaly of Patient</param>
        /// <param name="status">status of activity of Patient</param>
        /// <param name="checkTime1">first time to check patient vitalData</param>
        /// <param name="checkTime2">second time to check patient vitalData</param>
        /// <param name="kr">to reset Patients (go to hospital)-flag</param>
        /// <param name="id">for BackEnd to check if Patient has to be overrided</param>
        public Patient(string name, string firstName, DateTime dayOfBirth, Gender gender, string diagnosis, string telephoneNumber, string secondTelephoneNumber, int normalBloodPressure, int acceptableBloodPressure, int criticalBloodPressure, int normalPulse, int acceptablePulse, int criticalPulse, int normalWeight, int acceptableWeight, int criticalWeight, Status status, DateTime checkTime1, DateTime checkTime2, bool kr = false, int id = 0)
        {
            this.name = name;
            this.firstName = firstName;
            this.dateOfBirth = dayOfBirth;
            this.gender = gender;
            this.diagnosis = diagnosis;
            this.telephoneNumber = telephoneNumber;
            this.secondTelephoneNumber = secondTelephoneNumber;
            this.normalBloodPressure = normalBloodPressure;
            this.acceptableBloodPressure = acceptableBloodPressure;
            this.criticalBloodPressure = criticalBloodPressure;
            this.normalPulse = normalPulse;
            this.acceptablePulse = acceptablePulse;
            this.criticalPulse = criticalPulse;
            this.normalWeight = normalWeight;
            this.acceptableWeight = acceptableWeight;
            this.criticalWeight = criticalWeight;
            this.status = status;
            this.checkTime1 = checkTime1;
            this.checkTime2 = checkTime2;
            this.kr = kr;
            this.id = id;
        }


      /// <summary>
      /// method to check if patient ist feasible
      /// </summary>
      /// <returns>true if its feasible, false if not</returns>
      public bool isValidPatient()
      {
          bool ret = true;

          if ((this.checkTime1 == null)
               || (this.checkTime2 == null)
               || (this.name == null)
               || (this.firstName == null)
               || (this.gender == Gender.Keins)
               || (this.diagnosis == null)
               || (this.telephoneNumber == null)
               || (this.secondTelephoneNumber == null)
               || (this.normalBloodPressure == 0)
               || (this.normalPulse == 0)
               || (this.normalWeight == 0)
               || (this.status == Status.Keiner))
               {
                  ret = false;
               }
          return ret;
      }
   }
}
